#!/usr/bin/env python
# chmod a+x mapper.cfg
PACKAGE = "thermalvis"
import roslib; roslib.load_manifest("dynamic_reconfigure")
import roslib;roslib.load_manifest(PACKAGE)

# echo $PACKAGE

from dynamic_reconfigure.parameter_generator import *

gen = ParameterGenerator()

# MAJOR ACTIONS
gen.add("activateMapping", bool_t, 0, "Determines if new data is processed or skipped.", False)
gen.add("saveModel", bool_t, 0, "Saves the current model.", False)
gen.add("clearModel", bool_t, 0, "Clears the current model.", False)
gen.add("triggerShutdown", bool_t, 0, "Terminate the node.", False)
#gen.add("singleFrameMode", bool_t, 0, "Colorizes the model only with the most recent frame.", False)

gen.add("videoPoseRaycasting", bool_t, 0, "Use pose from video-based localization for raycasting.", False)

# MAJOR VARIABLES
#gen.add("autoSave", bool_t, 0, "Automatically saves the model when registration stops.", False)
#gen.add("autoClear", bool_t, 0, "Automatically resets the model when registration recovers.", False)
#gen.add("trancDist", double_t, 0, "Tranc Dist.", 0.003, 0.00, 3.00)

#gen.add("shiftingDistance", double_t, 0, "Maximimum amount of shift to allow before volume re-centering", 1.0, 0.01, 3.0)
#gen.add("verboseMode", bool_t, 0, "Increase text-based debug output", False)

# TIMING VARIABLES
#gen.add("thermalDelay", double_t, 0, "Lag of thermal camera timestamping compared to RGB camera", 0.0, -1.0, 1.0)
#gen.add("nearestNeighbourTimestamps", bool_t, 0, "Use just the closest timestamps, rather than interpolating", False);
#gen.add("maxTimeShift", double_t, 0, "Maximum difference in time (s) between a color/thermal frame and its closest-in-time depth frame for raycasting (NN-only)", 0.05, 0.0, 1.0)
#gen.add("maximumAge", double_t, 0, "Maximum allowable age (s) of the current thermal frame compared with the model for raycasting", 0.2, 0.0, 60.0)
#gen.add("maxTimeDiff", double_t, 0, "Maximum difference in time (s) between two depth pose estimates used for raycasting", 1.0, 0.0, 5.0)

# RENDERING VARIABLES
gen.add("displayColor", bool_t, 0, "Display color on the final model", True)
gen.add("displayThermal", bool_t, 0, "Display thermal on the final model", True)
# IMAGE PROCESSING VARIABLES
#gen.add("includeColor", bool_t, 0, "Include color processing in real time", True)
#gen.add("includeThermal", bool_t, 0, "Include thermal processing in real time", True)
#gen.add("checkDuplicates", bool_t, 0, "Avoid duplicates (not assuming valid markings from streamer)", False)
#gen.add("visibleBrightness", double_t, 0, "Scaling of visible channel PRE-fusion", 1.0, 0.0, 5.0)
gen.add("visibleScaling", double_t, 0, "Scaling of visible channels for fusion", 0.6, 0.0, 1.0)



#gen.add("displayConfidence", bool_t, 0, "Color points on model according to confidence from current thermal view", False)

#cloud_enum = gen.enum([ 
#	gen.const("FULL", int_t, 0, "Publish all points stored in model"),
#	gen.const("VIEW", int_t, 1, "Publish only points from current depth map"),
#	gen.const("NONE", int_t, 2, "Do not publish any points") ],
#	"An enum to set the nature of published point cloud")
#gen.add("cloudPublishMode", int_t, 0, "A cloud output parameter which is edited via an enum", 0, 0, 2, edit_method=cloud_enum)

mapping_enum = gen.enum([ 
	gen.const("GRAYSCALE", int_t, 0, "Grayscale coloring"),
	gen.const("CIECOMP", int_t, 1, "CIECOMP coloring"),
	gen.const("BLACKBODY", int_t, 2, "Blackbody coloring"),
	gen.const("RAINBOW", int_t, 3, "Rainbow coloring"),
	gen.const("IRON", int_t, 4, "Iron coloring"),
	gen.const("BLUERED", int_t, 5, "Blue-red coloring"),
	gen.const("JET", int_t, 6, "Jet coloring"),
	gen.const("CIELUV", int_t, 7, "CIELUV coloring"),
	gen.const("ICEIRON", int_t, 8, "Ice and iron coloring"),
	gen.const("ICEFIRE", int_t, 9, "Ice and fire coloring"),
	gen.const("REPEATED", int_t, 10, "Ice and fire coloring"),
	gen.const("HIGHLIGHTED", int_t, 11, "Highlights dominant pixels as red") ],
	"An enum to set the color mapping scheme")
                  
gen.add("map", int_t, 0, "A color mapping parameter which is edited via an enum", 7, 0, 11, edit_method=mapping_enum)
gen.add("normFactor", double_t, 0, "Proportion of temperatures at extremes to disregard for colorization", 0.0, 0.0, 1.0)
#gen.add("stepChangeTempScale", bool_t, 0, "When autoscaling temperature, sticks with discrete ranges", False)
gen.add("autoTemperature", bool_t, 0, "Automatically select temperature limits based on image range", True)
gen.add("minTemperature", double_t, 0, "Minimum temperature", 20.0, -50.0, 100.0)
gen.add("maxTemperature", double_t, 0, "Maximum temperature", 40.0, -50.0, 100.0)
gen.add("autoScaling", bool_t, 0, "Automatically scale fusion parameter to optimize visualization", True)
#gen.add("clampOutliers", bool_t, 0, "Fix outlying temperatures to the minimum or maximum, rather than disregarding", True)

#deadpoint_enum = gen.enum([ 
#	gen.const("GRAY", int_t, 0, "Dead points assigned [128, 128, 128]"),
#	gen.const("AXES", int_t, 1, "Dead points colored according to axes positions") ],
#	"An enum to set the dead point color scheme")              
#gen.add("deadPointMode", int_t, 0, "Option for how to color dead points", 1, 0, 1, edit_method=deadpoint_enum)

#gen.add("extremes", bool_t, 0, "Allow b/w color mapping", False)
#gen.add("minimumConfidence", double_t, 0, "Minimum confidence level before displaying the assigned value for a vertex", 0.0, 0.0, 1.0)

# WEIGHTINGS VARIABLES

# INCREASING THESE VARIABLES WILL ENFORCE A STRICTER REQUIREMENT FOR A NEAR-OPTIMAL OR IDEAL VALUE
gen.add("recencyBias", double_t, 0, "Bias towards favoring recent assignments over more confident assignments", 0.2, 0.0, 1.0)
gen.add("wgt_Normal", double_t, 0, "Thermal raycasting weighting for normals", 0.2, 0.0, 1.0)
gen.add("wgt_Radiometric", double_t, 0, "Thermal raycasting weighting for radiometric confidence", 0.0, 0.0, 1.0)
gen.add("wgt_Radial", double_t, 0, "Thermal raycasting weighting for radial position of pixel", 0.2, 0.0, 1.0)
gen.add("wgt_Distance", double_t, 0, "Thermal raycasting weighting for distance to point", 0.2, 0.0, 1.0)
gen.add("wgt_Velocity", double_t, 0, "Thermal raycasting weighting for velocity", 0.0, 0.0, 1.0)
gen.add("wgt_Edge", double_t, 0, "Thermal raycasting weighting for edges", 0.2, 0.0, 1.0)
gen.add("wgt_Occlusion", double_t, 0, "Thermal raycasting weighting for occlusion", 0.0, 0.0, 1.0)



# DEBUG
#gen.add("debugTiming", bool_t, 0, "Display debug information particularly relevant to timing issues", False)

# OBSOLETE
# gen.add("maxAngularVelocity", double_t, 0, "Maximum angular velocity (degrees per sec) between two depth pose estimates used for raycasting", 12, 0, 90)
#gen.add("maxTransVelocity", double_t, 0, "Maximum translational velocity (meters per sec) between two depth pose estimates used for raycasting", 0.25, 0.0, 1.0)

#gen.add("debugCalibration", bool_t, 0, "Allow real-time variation of calibration parameters.", False);
# gen.add("debug_I", int_t, 0, "Ability to vary thermal frame index for testing", 0, 0, 512);
#gen.add("debug_F", double_t, 0, "Ability to vary thermal focal length", 553.0, 0.0, 1000.0);
# gen.add("debug_X", double_t, 0, "Ability to vary thermal X shift", 0.02207, -0.1, 0.1);
# gen.add("debug_Y", double_t, 0, "Ability to vary thermal Y shift", -0.05250, -0.1, 0.1);
#gen.add("debug_Z", double_t, 0, "Ability to vary thermal Z shift", -0.05295, -0.1, 0.1);

exit(gen.generate(PACKAGE, "mapper", "mapper"))
